<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="/WEB-INF/jsp/base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>

<link rel="shortcut icon" href="favicon.ico">
<link href="css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<!-- Data Tables -->
<link href="css/plugins/dataTables/dataTables.bootstrap.css"
	rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="./css/plugins/sweetalert/sweetalert.css" rel="stylesheet">

<link href="css/style.min.css?v=4.0.0" rel="stylesheet">
<script src="./js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="./js/img_upload.js"></script>
<script type="text/javascript" src="./js/fileUploadUtil.js"></script>

<script type="text/javascript"></script>
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.5"></script>
<script src="js/plugins/jeditable/jquery.jeditable.js"></script>
<script src="js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="./js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="js/content.min.js?v=1.0.0"></script>
<script src="js/common.js"></script>
<style type="text/css">
.planTable {
	border-collapse: separate;
	border-spacing: 10px;
}
/* dataTables列内容居中 */
.table>tbody>tr>td {
	text-align: center;
}
/* dataTables表头居中 */
.table>thead:first-child>tr:first-child>th {
	text-align: center;
}
</style>

<script type="text/javascript">
	function FormatDate(date) {
		var y = date.getFullYear();
		var m = date.getMonth() + 1;
		var hour = date.getHours();
		var minute = date.getMinutes();
		m = m < 10 ? '0' + m : m;
		hour = hour < 10 ? '0' + hour : hour;
		minute = minute < 10 ? '0' + minute : minute;
		var d = date.getDate();
		d = d < 10 ? ('0' + d) : d;
		return y + '-' + m + '-' + d;
	}
</script>
<script type="text/javascript">
	var table;
	var darw = 0;
	$(function() {

		//提示信息
		var lang = {
			"sProcessing" : "<div style=\"float:right;width:50%\" >处理中...</div>",
			"sLengthMenu" : "每页 _MENU_ 项",
			"sZeroRecords" : "没有匹配结果",
			"sInfo" : "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
			"sInfoEmpty" : "当前显示第 0 至 0 项，共 0 项",
			"sInfoFiltered" : "(由 _MAX_ 项结果过滤)",
			"sInfoPostFix" : "",
			"sSearch" : "搜索:",
			"sUrl" : "",
			"sEmptyTable" : "表中数据为空",
			"sLoadingRecords" : "载入中...",
			"sInfoThousands" : ",",
			"oPaginate" : {
				"sFirst" : "首页",
				"sPrevious" : "上页",
				"sNext" : "下页",
				"sLast" : "末页",
				"sJump" : "跳转"
			},
			"oAria" : {
				"sSortAscending" : ": 以升序排列此列",
				"sSortDescending" : ": 以降序排列此列"
			}
		};

		//初始化表格
		table = $("#planDataTable")
				.dataTable(
						{

							"fnDrawCallback" : function() {

								var api = this.api();
								var startIndex = api.context[0]._iDisplayStart;//获取到本页开始的条数
								api.column(0).nodes().each(function(cell, i) {
									cell.innerHTML = startIndex + i + 1;
								});

							},
							language : lang, //提示信息
							autoWidth : false, //禁用自动调整列宽
							stripeClasses : [ "odd", "even" ], //为奇偶行加上样式，兼容不支持CSS伪类的场合
							processing : true, //隐藏加载提示,自行处理

							serverSide : true, //启用服务器端分页
							searching : false, //禁用原生搜索
							orderMulti : false, //启用多列排序
							order : [], //取消默认排序查询,否则复选框一列会出现小箭头
							renderer : "bootstrap", //渲染样式：Bootstrap和jquery-ui
							pagingType : "simple_numbers", //分页样式：simple,simple_numbers,full,full_numbers
							"bLengthChange" : false,
							ordering : false, //关闭排序图标
							// bStateSave:true,  //刷新 停留在当前页
							ajax : function(data, callback, settings) {
								//封装请求参数
								var param = {};
								param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
								param.start = data.start;//开始的记录序号
								param.page = (data.start / data.length) + 1;//当前页码
								// param.darw=darw;  //计数器

								var planTitle = $("#serachPlanTitle").val()
										.trim();
								if (planTitle != null && planTitle != "") {
									param.planTitle = planTitle;
								}

								//ajax请求数据
								$
										.ajax({
											type : "POST",
											url : "personalWorkPlanList.do",
											cache : false, //禁用缓存
											data : param, //传入组装的参数
											dataType : "json",
											success : function(result) {

												//setTimeout仅为测试延迟效果
												//封装返回数据
												var returnData = {};
												draw = result.draw;//后台返回的计数器
												returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
												returnData.recordsTotal = result.total;//返回数据全部记录
												returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
												returnData.data = result.data;//返回的数据列表

												//调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
												//此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕
												callback(returnData);
											},
											error : function() {
												sweetAlert("异常", "网络出现异常!",
														"error");
											}
										});
							},
							//列表表头字段
							columns : [

									{
										"data" : null
									},

									{
										"data" : "planId",
										"visible" : false
									},

									{
										"data" : "planTitle"
									},
									{
										"data" : "principal"
									},
									{
										"data" : "planType"
									},
									{
										"data" : "startDate"
									},
									{
										"data" : "endDate"
									},
									{
										"data" : function(data) {
											if (data.planContent == null) {
												return "";
											}
											if (data.planContent.length > 20) {
												return data.planContent.substr(
														0, 20)
														+ "...";
											} else {
												return data.planContent;
											}
										}
									}

							],
							columnDefs : [
									{
										"targets" : [ 8 ], //第14列加一条 自定义列
										"data" : "planId", //数据列名
										"render" : function(data, type, full) { //返回自定义的内容
											return "<a class=\"btn btn-info btn-xs\" onClick=\"planDetail("
													+ data
													+ ");\">详情</a> "
													+ "<a class=\"btn btn-primary  btn-xs\" onclick=\"modifyModal('"
													+ data
													+ "')\">修改</a> "
													+ "<a class=\"btn btn-danger btn-xs\" onClick=\"deleteChance("
													+ data + ");\">删除</a> ";
										}
									}, {
										"targets" : [ 5 ],
										"render" : function(data, type, full) {
											var startDate = new Date(data);
											return FormatDate(startDate);
										}
									}, {
										"targets" : [ 6 ],
										"render" : function(data, type, full) {
											var endDate = new Date(data);
											return FormatDate(endDate);
										}
									} ]
						})//.api();
		//此处需调用api()方法,否则返回的是JQuery对象而不是DataTables的API对象

	});
</script>
</head>
<body class="gray-bg">
	<div class="row">
		<div class="col-sm-12">
			<div class="ibox float-e-margins">
				<div class="ibox-title">
					<h5>个人工作计划列表</h5>
					<div class="ibox-content">
						<div class="input-group col-md-3"
							style="margin-top: 0px; positon: relative; float: left; bottom: -5px;">
							<input id="serachPlanTitle" type="text" class="form-control "
								placeholder="请输入关键字（计划标题、内容）"/ > <span
								class="input-group-btn">
								<button onclick="search()" class="btn btn-info btn-search">查询</button>
								<button class="btn btn-info btn-search"
									href="javascript:void(0);" onclick="addPlanBefore()"
									style="margin-left: 5px">添加</button>
							</span>
						</div>
						<table id="planDataTable"
							class="table table-striped table-bordered table-hover dataTables-example">
							<thead>
								<tr>
									<th>序号</th>
									<th>planId</th>
									<th>计划标题</th>
									<th>负责人</th>
									<th>计划类型</th>
									<th>开始时间</th>
									<th>结束时间</th>
									<th>计划内容</th>
									<th>操作</th>
								</tr>
							</thead>

						</table>
					</div>
				</div>
			</div>
		</div>
	</div>



	<!--添加的模态层  -->
	<div class="modal fade  " id='addPlanModal'>
		<div class="modal-dialog" style="width: 700px; height: 500px;">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss='modal'>×</button>
					<h2 class="modal-title" align="center">添加个人工作计划</h2>
				</div>

				<div class="modal-body" align="center">

					<form id="planFormInfo">
						<table id="addTable" class="planTable">
							<tr>
								<td>计划类型<span style="color: red;">*</span>：
								</td>
								<td><select class="form-control" name="planType"
									id="planType" onchange="addStartplanTypeBlur()">
										<option value="">-请选择-</option>
										<option>日计划</option>
										<option>周计划</option>
										<option>月计划</option>
										<option>一季度计划</option>
										<option>二季度计划</option>
										<option>三季度计划</option>
										<option>四季度计划</option>
										<option>年计划</option>
								</select></td>
							</tr>
							<tr>
								<td align="right">计划标题<span style="color: red;">*</span>：
								</td>
								<td><input type="text" name="planTitle" id="planTitle"
									class="form-control" placeholder="请输入计划标题"></td>
							</tr>
							<tr>
								<td align="right">负责人<span style="color: red;">*</span>：
								</td>
								<td><input type="text" name="principal" id="principal"
									class="form-control" placeholder="请输入负责人"></td>
							</tr>
							<tr>
								<td align="right">开始时间<span style="color: red;">*</span>：
								</td>
								<td><input type="text" name="startDate"
									class="form-control"
									onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})"
									placeholder="请输入开始时间" id="startDate" readonly="readonly"
									onfocus="addStartDateBlur()"></td>
							</tr>
							<tr>
								<td align="right">结束时间&nbsp;：</td>
								<td><input type="text" disabled="disabled" name="endDate1"
									class="form-control"
									onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})"
									placeholder="选择开始时间后自动生成" id="endDate"> <input
									type="hidden" name="endDate" class="form-control" id="endDate1"></td>
							</tr>
							<!-- <tr>
                        			<td>计划内容：</td>
                        			<td><input type="text" name="planContent" id="planContent"
											class="form-control"  ></td>
                        		</tr> -->
							<tr style="height: 70px">
								<td align="right">计划内容<span style="color: red;">*</span>：
								</td>
								<td><textarea style="resize: none;" rows="5" cols="65"
										name="planContent" id="planContent" class="form-control"></textarea></td>
							</tr>

						</table>
						<!-- <input type="text" id="graphicsText" name="graphicsText"> -->
						<!-- <input type="hidden"  name="status" value="0"> -->
					</form>

				</div>
				<div class="modal-footer" align="center">
					<div align="center">

						<button class="btn btn-primary" id="btnAddPlan"
							onclick="addPlan()">确认</button>
						<!-- <button class="btn btn-default" onclick="closeModal(addPlanModal)"
							id="btnAddClose">关闭</button> -->
					</div>
				</div>
			</div>
		</div>
	</div>

	<!--修改的模态层  -->
	<div class="modal fade  " id='modifyPlanModal'>
		<div class="modal-dialog" style="width: 700px; height: 500px;">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss='modal'>×</button>
					<h2 class="modal-title" align="center">修改个人工作计划</h2>
				</div>

				<div class="modal-body" align="center">

					<form id="modifyPlanForm">
						<table id="modifyTable" class="planTable">
							<tr>
								<td align="right">计划类型<span style="color: red;">*</span>：
								</td>
								<td><select class="form-control" name="planType"
									id="mplanType" onblur="startplanTypeBlur()">
										<option value="">-请选择-</option>
										<option>日计划</option>
										<option>周计划</option>
										<option>月计划</option>
										<option>一季度计划</option>
										<option>二季度计划</option>
										<option>三季度计划</option>
										<option>四季度计划</option>
										<option>年计划</option>
								</select></td>
							</tr>
							<tr>
								<td align="right">计划标题<span style="color: red;">*</span>：
								</td>
								<td><input type="text" name="planTitle" id="mplanTitle"
									class="form-control" placeholder="请输入计划标题"></td>
							</tr>
							<tr>
								<td align="right">负责人<span style="color: red;">*</span>：
								</td>
								<td><input type="text" name="principal" id="mprincipal"
									class="form-control" placeholder="请输入负责人"></td>
							</tr>
							<tr>
								<td align="right">开始时间<span style="color: red;">*</span>：
								</td>
								<td><input type="text" name="startDate"
									class="form-control"
									onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})"
									placeholder="请输入开始时间" id="mstartDate" onfocus="startDateBlur()"
									readonly="readonly"></td>
							</tr>
							<tr>
								<td align="right">结束时间&nbsp;：</td>
								<td><input type="text" disabled="disabled" name="endDate"
									class="form-control"
									onClick="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})"
									placeholder="请输入结束时间" id="mendDate"></td>
							</tr>
							<tr style="height: 70px">
								<td align="right">计划内容<span style="color: red;">*</span>：
								</td>
								<td><textarea style="resize: none;" rows="5" cols="65"
										name="planContent" id="mplanContent" class="form-control"></textarea></td>
							</tr>
						</table>
						<input type="hidden" name="planId" id="mplanId">
					</form>

				</div>
				<div class="modal-footer" align="center">
					<div align="center">
						<button class="btn btn-primary" id="btnAddPlan"
							onclick="modifyPlan()">确认</button>
						<!-- <button class="btn btn-default"
							onclick="closeModal(modifyPlanModal)" id="btnAddClose">关闭</button> -->
					</div>
				</div>
			</div>
		</div>
	</div>



	<!--详细信息的模态层  -->
	<div class="modal fade  " id='planDetailModal'>
		<div class="modal-dialog" style="width: 700px; height: 500px;">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" data-dismiss='modal'>×</button>
					<h2 class="modal-title" align="center">个人工作计划详情</h2>
				</div>
				<div class="modal-body" align="center">
					<form>
						<table id="modifyTable" class="chanceTable">
							<tr style="height: 40px">
								<td align="right">计划标题：</td>
								<td><span disabled="disabled" id="splanTitle"
									class="form-control"></span></td>
							</tr>
							<tr style="height: 40px">
								<td align="right">计划类型：</td>
								<td><span disabled="disabled" id="splanType"
									class="form-control"></span></td>
							</tr>
							<tr style="height: 40px">
								<td align="right">负责人：</td>
								<td><span disabled="disabled" id="sprincipal"
									class="form-control"></span></td>
							</tr>
							<tr style="height: 40px">
								<td align="right">开始时间：</td>
								<td><span disabled="disabled" class="form-control"
									id="sstartDate"></span></td>
							</tr>
							<tr style="height: 40px">
								<td align="right">结束时间：</td>
								<td><span disabled="disabled" class="form-control"
									id="sendDate"> </span></td>
							</tr>
							<!-- <tr>
									<td>计划内容：</td>
									<td><span id="splanContent" class="form-control"></span></td>
								</tr> -->
							<tr style="height: 130px">
								<td align="right">计划内容：</td>
								<td><textarea style="resize: none;" rows="5" cols="65"
										name="splanContent" id="splanContent" class="form-control"
										disabled="disabled"></textarea></td>
							</tr>
						</table>
						<!-- 	<input type="hidden"  name="chanceId" id="mchanceId" > -->
					</form>

				</div>
				<div class="modal-footer" align="center">
					<div align="center">
						<button class="btn btn-primary" id="btnAddChance"
							onclick="closeModal(planDetailModal)">确认</button>
					</div>
				</div>
			</div>
		</div>
	</div>


	<script>
		//显示modal
		function showModal(modal) {
			$(modal).modal("show");
		}
		//隐藏modal
		function closeModal(modal) {
			$(modal).modal("hide");
		}

		//添加计划前清空添加模态框中的数据
		function addPlanBefore() {
			$("#planTitle").val("");
			$("#principal").val("");
			$("#planType").val("");
			$("#planContent").val("");
			$("#startDate").val("");
			$("#endDate").val("");
			showModal(addPlanModal);
		}

		//添加计划
		function addPlan() {
			var planTitle = $("#planTitle");
			var principal = $("#principal");
			var planType = $("#planType");
			var planContent = $("#planContent");
			var startDate = $("#startDate");
			var endDate = $("#endDate");

			if (planTitle.val().trim() == "") {
				swal("提示", "计划标题不能为空!", "warning");
				return false;
			}
			if (principal.val().trim() == "") {
				swal("提示", "负责人不能为空!", "warning");
				return false;
			}
			if (planType.val().trim() == "") {
				swal("提示", "请选择计划类型!", "warning");
				return false;
			}
			if (planContent.val().trim() == "") {
				swal("提示", "计划内容不能为空!", "warning");
				return false;
			}
			if (startDate.val().trim() == "") {
				swal("提示", "请选择开始时间!", "warning");
				return false;
			}
			if (endDate.val().trim() == "") {
				swal("提示", "请选择结束时间!", "warning");
				return false;
			}

			//执行添加
			$.ajax({
				url : "insertPersonalWorkPlan.do",
				data : $("#planFormInfo").serializeArray(),
				dataType : "json",
				type : "post",
				success : function(result) {
					if (result.code == 1) {
						swal({
							title : "提示",
							text : result.msg,
							type : "success",
							confirmButtonColor : "#DD6B55",
							confirmButtonText : "确定",
							closeOnConfirm : true
						}, function() {
							$("serachPlanTitle").val("");
							search()
							$("#addPlanModal").modal("hide");
						});

					} else if (result.code == 0) {
						swal("异常", result.msg, "error");
					} else {
						swal("错误", result.msg, "error");
					}
				},
				error : function() {
					swal("错误", "系统出现错误!", "error");
				}
			});
		}

		//修改机会信息的模态层
		function modifyModal(planId) {
			$
					.ajax({
						url : "modifyPersonalWorkPlanQuery.do",
						data : {
							"planId" : planId
						},
						dataType : "json",
						type : "post",
						success : function(result) {
							if (result.flag == 1) {
								$("#mplanId").val(
										result.personalWorkPlan.planId);
								$("#mplanTitle").val(
										result.personalWorkPlan.planTitle);
								$("#mprincipal").val(
										result.personalWorkPlan.principal);
								//遍历计划类型select

								$("#mplanType").val(
										result.personalWorkPlan.planType);

								var startDate = new Date(
										result.personalWorkPlan.startDate);//时间戳转换为java.util.date
								startDate = FormatDate(startDate);//抽取出来年月日
								$("#mstartDate").val(startDate);

								var endDate = new Date(
										result.personalWorkPlan.endDate);//时间戳转换为java.util.date
								endDate = FormatDate(endDate);//抽取出来年月日
								$("#mendDate").val(endDate);

								$("#mplanContent").val(
										result.personalWorkPlan.planContent);

								$("#modifyPlanModal").modal("show");

							} else if (result.flag == 0) {
								swal("异常", "暂无数据,请稍后再试!", "warning")
							}
						},
						error : function() {
							swal("错误", "系统异常,请稍后再试!", "error")
						}
					});
		}

		//修改计划
		function modifyPlan() {

			var planTitle = $("#mplanTitle").val();
			var principal = $("#mprincipal").val();
			var planType = $("#mplanType").val();
			var planContent = $("#mplanContent").val();
			var startDate = $("#mstartDate").val();
			var endDate = $("#mendDate").val();
			var planId = $("#mplanId").val();

			if (planTitle.trim() == "") {
				swal("提示", "计划标题不能为空!", "warning");
				return false;
			}

			if (principal.trim() == "") {
				swal("提示", "负责人不能为空!", "warning");
				return false;
			}
			if (planType.trim() == "") {
				swal("提示", "请选择计划类型!", "warning");
				return false;
			}
			if (planContent.trim() == "") {
				swal("提示", "计划内容不能为空!", "warning");
				return false;
			}
			if (startDate.trim() == "") {
				swal("提示", "请选择开始时间!", "warning");
				return false;
			}
			if (endDate.trim() == "") {
				swal("提示", "请选择结束时间!", "warning");
				return false;
			}

			$.ajax({
				url : "modifyPersonalWorkPlan.do",
				data : {
					planTitle : planTitle,
					principal : principal,
					planType : planType,
					planContent : planContent,
					startDate : startDate,
					endDate : endDate,
					planId : planId
				},
				type : "post",
				dataType : "json",
				success : function(result) {
					if (result.flag == 1) {
						swal({
							title : "提示",
							text : result.msg,
							type : "success",
							confirmButtonColor : "#DD6B55",
							confirmButtonText : "确定",
							closeOnConfirm : true
						}, function() {
							search()
							$("#modifyPlanModal").modal("hide");
						});

					} else if (flag == 0) {
						swal("异常", result.msg, "error");
					} else {
						swal("异常", "程序异常,请稍后再试!", "error");
					}

				},
				error : function() {
					swal("异常", "程序异常,请稍后再试!", "error");
				}

			});

		}

		//删除数据提示函数
		function deleteChance(id) {
			var AjaxURL = "deletePersonalWorkPlan.do";
			swal({
				title : "提示",
				text : "您确定要删除这条信息吗！",
				type : "warning",
				showCancelButton : true,
				confirmButtonColor : "#DD6B55",
				confirmButtonText : "删除",
				cancelButtonText : "取消",
				closeOnConfirm : false
			}, function() {
				//如果确认，异步处理删除动作
				$.ajax({
					type : "post",
					dataType : "json",
					url : AjaxURL,
					data : {
						"id" : id
					},
					success : function(data) {
						if (data.code == "success") {
							swal({
								title : "提示",
								text : data.msg,
								type : "success",
								confirmButtonColor : "#DD6B55",
								confirmButtonText : "确定",
								closeOnConfirm : true
							}, function() {
								search()
							});
						} else {
							swal("异常", data.msg, "error")
						}
					},
					error : function() {
						swal("错误", "未知错误请联系管理员！", "error")
					}
				});
			});
		}

		//查看机会详细信息
		function planDetail(planId) {
			$
					.ajax({
						url : "modifyPersonalWorkPlanQuery.do",
						data : {
							"planId" : planId
						},
						dataType : "json",
						type : "post",
						success : function(result) {
							if (result.flag == 1) {
								//$("#schanceId").text(result.chance.chanceId);
								$("#planId").text(
										result.personalWorkPlan.planId);
								$("#splanTitle").text(
										result.personalWorkPlan.planTitle);
								$("#sprincipal").text(
										result.personalWorkPlan.principal);
								//$("#mintentionProducts").text(result.chance.intentionProducts);
								//遍历计划类型select

								$("#splanType").text(
										result.personalWorkPlan.planType);
								/* $("#mplanType").each(function(){
									if($(this).text().trim()==result.personalWorkPlan.planType.trim()){
										$(this).prop("selected","selected");
									}
								}); */

								var startDate = new Date(
										result.personalWorkPlan.startDate);//时间戳转换为java.util.date
								startDate = FormatDate(startDate);//抽取出来年月日
								$("#sstartDate").text(startDate);

								var endDate = new Date(
										result.personalWorkPlan.endDate);//时间戳转换为java.util.date
								endDate = FormatDate(endDate);//抽取出来年月日
								$("#sendDate").text(endDate);

								$("#splanContent").text(
										result.personalWorkPlan.planContent);
								$("#planDetailModal").modal("show");

							} else if (result.flag == 0) {
								swal("异常", "暂无数据,请稍后再试!", "warning")
							}
						},
						error : function() {
							swal("错误", "系统异常,请稍后再试!", "error")
						}
					});
		}
		//搜索
		function search() {
			table.fnDraw();
		}

		//修改计划日期的处理
		function startDateBlur() {
			var startDate = $("#mstartDate").val();
			var planType = $("#mplanType").val();
			startDate = startDate.replace(/-/g, "/");//将时间中的/变为-
			var date = new Date(startDate);
			if (planType == "日计划") {
				if (startDate != "") {
					$("#mendDate").val(FormatDate(date));
				}
			} else if (planType == "周计划") {
				if (startDate != "") {
					date.setDate(date.getDate() + 7)
					$("#mendDate").val(FormatDate(date));
				}
			} else if (planType == "月计划") {
				if (startDate != "") {
					date.setMonth(date.getMonth() + 1)
					$("#mendDate").val(FormatDate(date));
				}
			} else if (planType == "年计划") {
				if (startDate != "") {
					date.setYear(date.getFullYear() + 1)
					$("#mendDate").val(FormatDate(date));
				}
			} else if (planType == "" || planType == null) {
				swal("提示", "请先选择计划类型!", "warning");
				$("#mstartDate").val("");
				$("#mendDate").val("");
			}
		}
		function startplanTypeBlur() {
			var planType = $("#mplanType").val();
			if (planType == "一季度计划") {
				var date = new Date();
				$("#mstartDate").val(date.getFullYear() + "-01-01");
				$("#mendDate").val(date.getFullYear() + "-03-31");
				$('#mstartDate').attr("disabled", true)
				$('#mendDate').attr("disabled", true)
			} else if (planType == "二季度计划") {
				var date = new Date();
				$("#mstartDate").val(date.getFullYear() + "-04-01");
				$("#mendDate").val(date.getFullYear() + "-06-30");
				$('#mstartDate').attr("disabled", true)
				$('#mendDate').attr("disabled", true)
			} else if (planType == "三季度计划") {
				var date = new Date();
				$("#mstartDate").val(date.getFullYear() + "-07-01");
				$("#mendDate").val(date.getFullYear() + "-09-30");
				$('#mstartDate').attr("disabled", true)
				$('#mendDate').attr("disabled", true)
			} else if (planType == "四季度计划") {
				var date = new Date();
				$("#mstartDate").val(date.getFullYear() + "-10-01");
				$("#mendDate").val(date.getFullYear() + "-12-31");
				$('#mstartDate').attr("disabled", true)
				$('#mendDate').attr("disabled", true)
			} else {
				$('#mstartDate').attr("disabled", false);
				$('#mendDate').attr("disabled", true)
			}
		}

		//添加计划日期的处理
		function addStartDateBlur() {
			var startDate = $("#startDate").val();
			var planType = $("#planType").val();
			startDate = startDate.replace(/-/g, "/");//将时间中的/变为-
			var date = new Date(startDate);
			if (planType == "日计划" && startDate != "") {
				$("#endDate").val(FormatDate(date));
				$("#endDate1").val(FormatDate(date));
			} else if (planType == "周计划" && startDate != "") {
				date.setDate(date.getDate() + 7)
				$("#endDate").val(FormatDate(date));
				$("#endDate1").val(FormatDate(date));
			} else if (planType == "月计划" && startDate != "") {
				date.setMonth(date.getMonth() + 1)
				$("#endDate").val(FormatDate(date));
				$("#endDate1").val(FormatDate(date));
			} else if (planType == "年计划" && startDate != "") {
				date.setYear(date.getFullYear() + 1)
				$("#endDate").val(FormatDate(date));
				$("#endDate1").val(FormatDate(date));
			} else if (planType == "" || planType == null) {
				swal("提示", "请先选择计划类型!", "warning");
				$("#startDate").val("");
				$("#endDate").val("");
			}
		}
		function addStartplanTypeBlur() {
			var planType = $("#planType").val();
			if (planType == "一季度计划") {
				var date = new Date();
				$("#startDate").val(date.getFullYear() + "-01-01");
				$("#endDate").val(date.getFullYear() + "-03-31");
				$("#endDate1").val(date.getFullYear() + "-03-31");
				$('#startDate').attr("disabled", true)
				$('#endDate').attr("disabled", true)
			} else if (planType == "二季度计划") {
				var date = new Date();
				$("#startDate").val(date.getFullYear() + "-04-01");
				$("#endDate").val(date.getFullYear() + "-06-30");
				$("#endDate1").val(date.getFullYear() + "-06-30");
				$('#startDate').attr("disabled", true)
				$('#endDate').attr("disabled", true)
			} else if (planType == "三季度计划") {
				var date = new Date();
				$("#startDate").val(date.getFullYear() + "-07-01");
				$("#endDate").val(date.getFullYear() + "-09-30");
				$("#endDate1").val(date.getFullYear() + "-09-30");
				$('#startDate').attr("disabled", true)
				$('#endDate').attr("disabled", true)
			} else if (planType == "四季度计划") {
				var date = new Date();
				$("#startDate").val(date.getFullYear() + "-10-01");
				$("#endDate").val(date.getFullYear() + "-12-31");
				$("#endDate1").val(date.getFullYear() + "-12-31");
				$('#startDate').attr("disabled", true)
				$('#endDate').attr("disabled", true)
			} else {
				$('#startDate').attr("disabled", false);
				$('#endDate').attr("disabled", true)
			}
		}
	</script>
</body>
</html>